Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Under JSON Create containing directory for config file. #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rgammans
Copy link
Contributor

Using '~/.config/$(APPNAME)/..' is a pretty common on Linux
but using it here will fail if the directory isn't manually created.

This fixes that by auto-creating the directory.

@Kentzo
Copy link
Member

Kentzo commented May 27, 2020

In our own products we relied on installation scripts to create directories with correct ownership and permissions. I think it's responsibility of lib's user to make sure needed paths exist.

It may appear simple when it's something as innocent as ~/.config, but that's not always the case. Even with ~/.config consider the case when user runs your app with sudo by mistake. Such directory would cause a lot of headache.

In general I suggest to run validation and directory creation early in your app to address this problem. Then you can gracefully handle cases when $HOME and $EUID represent different users.

@rgammans
Copy link
Contributor Author

I agree that auto-creating directories could be dangerous, but we already auto-create a file, so much of the same concerns hold there. I did worry about it for a bit but it then end - it comes down ensuring sane paths are used. On my systems under sudo '~' expands to '/root'; so it's not a weird outcome. Any use of sudo is dangerous; I don't think this is any worse than say 'rm'

Perhaps this should be an option - wouldn't want to put OS-specifics like this (windows - for example won't need this) is the library use; the whole point of library is abstract away Os specific cases.

Using '~/.config/$(APPNAME)/..' is a pretty common on linux
but using it here will fail if the directory isn't manually created.

This fixes that by auto creating the directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants